import { parseTimeDot } from "@/utils/utils.js";
export default {
	data() {
		return {
			parseTimeDot,
			// 展示最新消息
			getShowMessage: function(item) {
				if (!item.lastMessage) return "";
				let type = JSON.parse(item.lastMessage.extendedData).type;
				if (type == 11) return "[图片]";
				else if (type == 111) return "[表情]";
				else return item.lastMessage.message;
			},
			// filteredList: [],
			listTouchStart: 0,
			listTouchDirection: null,
			modalName: null,
			delShow: false,
			delId: null,
			delShow: false,
		};
	},
	onReady() {},
	onShow() {
		this.$store.dispatch('queryConversationList')
	},
	computed: {},
	methods: {

		go(item) {
			uni.navigateTo({
				url: '/enterpriseServer/chatRoom/index?id=' + item.conversationID
			});
		},

		//删除
		deleteConversation(item) {
			this.delShow = true;
			this.delId = item.conversationID;
		},

		confirmDel() {
			this.delShow = false;
			this.$store.commit('del_ConversationList', {
				id: this.delId
			})
		},

		// ListTouch触摸开始
		ListTouchStart(e) {
			this.listTouchStart = e.touches[0].pageX
		},

		// ListTouch计算方向
		ListTouchMove(e) {
			this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
		},

		// ListTouch计算滚动
		ListTouchEnd(e) {
			if (this.listTouchDirection == 'left') {
				this.modalName = e.currentTarget.dataset.target
			} else {
				this.modalName = null
			}
			this.listTouchDirection = null
		}

	}
}